import { createRouter, createWebHashHistory } from 'vue-router'
// import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    name: 'layout',
    component: () => import(/* webpackChunkName: "about" */ '@/views/Layout/'),
    children: [
      {
        path: '',
        name: 'home',
        component: () => import(/* webpackChunkName: "about" */ '@/views/Home')
      },
      {
        path: 'category/:id',
        name: 'category',
        component: () => import(/* webpackChunkName: "about" */ '@/views/Category')
      },
      {
        path: '/category/sub/:id',
        component: () => import(/* webpackChunkName: "about" */ '@/views/Category/Sub')
      },
      {
        path: '/goods/:id',
        component: () => import(/* webpackChunkName: "about" */ '@/views/Goods')
      },
      {
        path: '/settlement',
        component: () => import('@/views/Settlement')
      },
      {
        path: '/pay',
        component: () => import('@/views/Pay')
      },
      {
        path: '/pay/callback',
        component: () => import('@/views/Pay/callback.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/login')
  },
  {
    path: '/login/callback',
    component: () => import('@/views/login/callback')
  },
  {
    path: '/cart',
    component: () => import('@/views/Cart')
  }
]

const router = createRouter({
  // 刷新后跳至最顶部
  scrollBehavior: () => ({ y: 0, x: 0 }),
  history: createWebHashHistory(),
  routes
})

export default router
